﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.master" CodeBehind="BirthCertificate.aspx.cs"
    Inherits="CivilRegistry.BirthCertificate" %>

<%@ Register Src="~/UserControls/UCUserGadget.ascx" TagName="UserGadget" TagPrefix="UC" %>
<asp:Content ID="headerContent" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function ReasonVisible(actionName) {
            if ($('#<%=btnDeactivate.ClientID%>').val() == "Deactivate") {
                if ($('#<%=lblReason.ClientID%>').css('visibility') == 'hidden') {
                    $('#<%=lblReason.ClientID%>').css('visibility', 'visible');
                    $('#<%=txtReason.ClientID%>').css('visibility', 'visible');
                    return false;
                }
                else if ($('#<%=txtReason.ClientID%>').val() == '') {
                    $('#<%=lblReasonValidation.ClientID%>').css('visibility', 'visible');
                    $('#<%=lblReasonValidation.ClientID%>').text('Please enter the reason for ' + actionName);
                    return false;
                }
            }

            if ($('#<%=btnDeny.ClientID%>').val() == "Deny") {
                if ($('#<%=lblReason.ClientID%>').css('visibility') == 'hidden') {
                    $('#<%=lblReason.ClientID%>').css('visibility', 'visible');
                    $('#<%=txtReason.ClientID%>').css('visibility', 'visible');
                    return false;
                }
                else if ($('#<%=txtReason.ClientID%>').val() == '') {
                    $('#<%=lblReasonValidation.ClientID%>').css('visibility', 'visible');
                    $('#<%=lblReasonValidation.ClientID%>').text('Please enter the reason for ' + actionName);
                    return false;
                }
            }

            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="maincontent" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <div class="mainContent">
            <asp:Panel ID="pnlNews" runat="server">
            </asp:Panel>
            <asp:Panel ID="pnlAdmin" runat="server">
                <asp:Panel ID="pnlTools" runat="server">
                    <asp:Button ID="btnViewAll" runat="server" Text="View All" OnClick="btnViewAll_Click"
                        CssClass="button greenButton medium" />
                    <asp:Button ID="btnViewBirthCertificateRequest" Text="View Birth-Certificate Requests"
                        CssClass="button greenButton medium" runat="server" OnClick="btnViewBirthCertificateRequest_Click" />
                </asp:Panel>
                <div class="form-content">
                    <asp:Panel ID="pnlFilter" runat="server" CssClass="filter" Visible="false">
                        <span style="float: left; margin-top: 3px">Filter(If none is checked, all will be displayed.):</span>
                        <asp:CheckBoxList ID="cblFilter" RepeatDirection="Horizontal" runat="server" AutoPostBack="true"
                            OnSelectedIndexChanged="cblFilter_SelectedIndexChanged">
                            <asp:ListItem Text="Approved" Value="Approved"></asp:ListItem>
                            <asp:ListItem Text="Deactivated" Value="Deactivated"></asp:ListItem>
                        </asp:CheckBoxList>
                    </asp:Panel>
                </div>
                <div class="form-content" style="float: left;">
                    <asp:GridView ID="gvBirthCertificate" runat="server" AllowPaging="true" AutoGenerateColumns="False"
                        CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
                        EmptyDataText="No records found!" AllowSorting="true" OnSorting="gvBirthCertificate_Sorting"
                        OnPageIndexChanging="gvBirthCertificate_PageIndexChanging" OnRowCommand="gvBirthCertificate_RowCommand"
                        OnRowEditing="gvBirthCertificate_RowEditing" BorderWidth="2px">
                        <HeaderStyle VerticalAlign="Top" BackColor="#003366" ForeColor="White" />
                        <RowStyle BackColor="White" ForeColor="Black" />
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:HiddenField ID="hdnBirthCertificateId" runat="server" Value='<%# Eval("BirthCertificateId") %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="First Name" DataField="ChildFirshtName" SortExpression="ChildFirshtName" />
                            <asp:BoundField HeaderText="Middle Name" DataField="ChildMiddleName" SortExpression="ChildMiddleName" />
                            <asp:BoundField HeaderText="Last Name" DataField="ChildLastName" SortExpression="ChildLastName" />
                            <asp:BoundField HeaderText="IsApproved" DataField="IsApproved" />
                            <asp:TemplateField HeaderText="Action">
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnEdit" CommandName="Edit" CommandArgument='<%# Container.DataItemIndex %>'
                                        runat="server">Edit</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </div>
            </asp:Panel>
            <div class="form-content">
                <asp:Panel ID="pnlDisplay" runat="server">
                    <asp:HiddenField ID="hdnBirthCertificateId" runat="server" />
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblFirstName" runat="server" Text="First Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblFirstNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblMiddleName" runat="server" Text="Middle Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblMiddleNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblLastName" runat="server" Text="Last Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblLastNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblDateOfBirth" runat="server" Text="Date Of Birth:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblDateOfBirthValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblGender" runat="server" Text="Gender:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblGenderValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblCivilHospital" runat="server" Text="Civil Hospital:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblCivilHospitalValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div>
                    </div>
                    <div class="bottomButtons">
                        <asp:Button ID="btnApply" Text="Apply Birth Certificate for Child" runat="server"
                            OnClick="btnApply_Click" CssClass="button greenButton medium" />
                    </div>
                </asp:Panel>
                <center>
                    <asp:Label ID="lblStatus" runat="server" BackColor="Yellow" ForeColor="DarkBlue" Font-Bold="true"></asp:Label>
                </center>
                <asp:Panel ID="pnlAdminActions" runat="server" Visible="false">
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1 bottomButtons">
                            <asp:Button ID="btnApprove" runat="server" Text="Approve" OnClick="btnApprove_Click"
                                CssClass="button greenButton medium" />
                            <asp:Button ID="btnDeactivate" runat="server" Text="Deactivate" CssClass="button red medium"
                                OnClientClick="return ReasonVisible('Deactivate');" OnClick="btnDeactivate_Click" />
                            <asp:Button ID="btnDeny" runat="server" Text="Deny" CssClass="button red medium"
                                OnClientClick="return ReasonVisible('Deny');" OnClick="btnDeny_Click" />
                            <asp:Label ID="lblReason" Style="visibility: hidden;" runat="server" Text="Reason:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:TextBox ID="txtReason" Style="visibility: hidden;" runat="server" TextMode="MultiLine"
                                Rows="5"></asp:TextBox>
                            <asp:Label ID="lblReasonValidation" Style="visibility: hidden;" runat="server" CssClass="redText"></asp:Label>
                        </div>
                    </div>
                </asp:Panel>
                <asp:Panel ID="pnlBirthCertificateRequest" Visible="false" runat="server">
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblBRFirstName" runat="server" Text="First Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtFirstName"
                                CssClass="redText" ErrorMessage="Please enter the first name."></asp:RequiredFieldValidator>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblBRMiddleName" runat="server" Text="Middle Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:TextBox ID="txtMiddleName" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtMiddleName"
                                CssClass="redText" ErrorMessage="Please enter the middle name"></asp:RequiredFieldValidator>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblBRLastName" runat="server" Text="Last Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblVerificationCode" runat="server" Text="Verification Code:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:TextBox ID="txtVerificationCode" ToolTip="Code provided by a hospital" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtVerificationCode"
                                CssClass="redText" ErrorMessage="Please enter the verification code"></asp:RequiredFieldValidator>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblRelationshipWithChild" runat="server" Text="Relationship with child:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:RadioButtonList ID="rblRelation" runat="server">
                                <asp:ListItem Text="Father" Value="F"></asp:ListItem>
                                <asp:ListItem Text="Mother" Value="M"></asp:ListItem>
                                <asp:ListItem Text="Gaurdian" Value="G"></asp:ListItem>
                            </asp:RadioButtonList>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fr txtlft divsize2">
                            <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="button greenButton medium"
                                OnClick="btnSubmit_Click" />
                        </div>
                    </div>
                </asp:Panel>
            </div>
        </div>
        <div class="Gadget">
            <UC:UserGadget ID="ucUserGadget" runat="server" />
        </div>
    </div>
</asp:Content>
